<template>
  <JmReport chartId="908594207897214976" :params="reportParams" />
</template>

<script lang="ts" setup>
  import { ref, watch } from 'vue';
  import JmReport from '/@/components/JmReport/index.vue';

  import { useMessage } from '/@/hooks/web/useMessage';
  import { saveOrUpdate } from '../api';
  const props = defineProps({
    formDisabled: { type: Boolean, default: false },
    fData: { type: Object, default: () => {} },
    formBpm: { type: Boolean, default: true },
  });

  const emit = defineEmits(['register', 'ok']);
  const { createMessage } = useMessage();

  const reportParams = ref({ id: '', assetId: '' });
  watch(
    props.fData,
    () => {
      reportParams.value.id = props.fData.id;
      reportParams.value.assetId = props.fData.assetList;
      console.log(reportParams.value, ' reportParams.value.');
    },
    { deep: true, immediate: true }
  );
  /**
   * 提交数据
   */
  function submitForm() {
    saveOrUpdate({ ...props.fData, status: '2' }, true).then((res) => {
      if (res.success) {
        createMessage.success('提交成功');
        emit('ok', res.result);
      } else {
        createMessage.warning(res.message);
        emit('ok', res.result);
      }
    });
  }

  defineExpose({
    submitForm,
  });
</script>

<style lang="less" scoped>
  .antd-modal-form {
    min-height: 500px !important;
    overflow-y: auto;
    padding: 24px 24px 24px 24px;
  }
  .info-title {
    font-size: 15px;
    font-weight: 600;
  }
</style>
../AssetUse.api
